<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 5. Actors</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Clutter编程" />
    <link rel="up" href="index.html" title="Clutter编程" />
    <link rel="prev" href="sec-stage-widget.html" title="Stage Widget" />
    <link rel="next" href="sec-actors-transformations.html" title="Transformations" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 5. Actors</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="sec-stage-widget.html"><img src="../icons/prev.png" alt="Prev" /></a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="sec-actors-transformations.html"><img src="../icons/next.png" alt="Next" /></a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="sec-actors"></a>Chapter 5. Actors</h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <ul>
          <li>
            <span class="sect1">
              <a href="sec-actors.html#sec-actors-basics">Actor 基础</a>
            </span>
          </li>
          <li>
            <span class="sect1">
              <a href="sec-actors-transformations.html">Transformations</a>
            </span>
          </li>
          <li>
            <span class="sect1">
              <a href="sec-containers.html">容器</a>
            </span>
          </li>
          <li>
            <span class="sect1">
              <a href="sec-actors-events.html">事件</a>
            </span>
          </li>
        </ul>
      </div>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="sec-actors-basics"></a>Actor 基础</h2>
            </div>
          </div>
        </div>
        <p>
<a class="link" href="sec-clutter.html" title="Clutter 简介">简介</a>一章已提到， <span class="application">Clutter</span> is a canvas API for 2D surfaces in 3D space. 
标准的 <span class="application">Clutter</span> actors 具有 2D 形状，能够在三维空间定位和旋转，但它们没有深度。
因此理论上讲，当恰好旋转到边面对屏幕时，actor 不可见。当需要复杂的 3D 对象时，就
需要使用 OpenGL ES API 了，附录 <a class="link" href="appendix-implementing-actors.html" title="Appendix A. Implementing Actors">Implementing Actors</a> 有相关阐述。
现在，我们看下标准的 actor ：
</p>
        <div class="itemizedlist">
          <ul type="disc">
            <li>
              <p><a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterStage.html" target="_top">ClutterStage</a>: stage，前一章已提到；</p>
            </li>
            <li>
              <p><a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterRectangle.html" target="_top">ClutterRectangle</a>: 一个矩形；</p>
            </li>
            <li>
              <p><a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterLabel.html" target="_top">ClutterLabel</a>: 显示文本；</p>
            </li>
            <li>
              <p><a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterEntry.html" target="_top">ClutterEntry</a>: 可以被编辑的文本；</p>
            </li>
            <li>
              <p><a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterTexture.html" target="_top">ClutterTexture</a>: 图象。</p>
            </li>
          </ul>
        </div>
        <p>
</p>
        <p>
每个 actor 都应该调用 <code class="function">clutter_container_add()</code> 函数加入 stage，紧接着要指定它的位置。所有的 actor 都继承自 <code class="classname">ClutterActor</code>，所有可以通过调用 <code class="function">clutter_actor_set_position()</code> 设置 x 和 y 坐标，用 <code class="function">clutter_actor_set_depth()<code class="function"> 设置 z 坐标，用 </code>clutter_actor_set_size()</code> 设置宽和高。
</p>
        <p>
ctor 的位置是以其所在容器(如 stage)的左上角为原点 , 但原点可以调用 <code class="function">clutter_actor_set_anchor_point()</code> 改变。
</p>
        <p>
缺省状态下，actor 是隐藏的，所以要记得调用 <code class="function">clutter_actor_show()</code> 显示 actor，之后也可以调用 <code class="function">clutter_actor_hide()</code> 隐藏它。
</p>
        <p>
Like <span class="application">GTK+</span> widgets, <span class="application">Clutter</span> actors have a "floating reference" when they are first instantiated with a function 
such as <code class="function">clutter_rectangle_new()</code>. This reference is then taken when the actor is added to a container, 
such as the stage. This means that you do not need to unreference the actor after creating it.
</p>
        <p>
Actor 可以进行缩放、旋转、部分透明等变换。
</p>
        <p>
          <a class="ulink" href="http://clutter-project.org/docs/clutter/0.8/ClutterActor.html" target="_top">Reference</a>
        </p>
        <div class="sect2" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h3 class="title"><a id="actor-example"></a>示例</h3>
              </div>
            </div>
          </div>
          <p>
下面的例子实现了 stage 中两个不移动的 actor:
</p>
          <div class="figure">
            <a id="figure-actor"></a>
            <p class="title">
              <b>Figure 5.1. Actor</b>
            </p>
            <div class="figure-contents">
              <div class="screenshot">
                <div>
                  <img src="./figures/actors.png" alt="Actor" />
                </div>
              </div>
            </div>
          </div>
          <br class="figure-break" />
          <p>
            <a class="ulink" href="./examples/actor" target="_top">Source Code</a>
          </p>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="sec-stage-widget.html"><img src="../icons/prev.png" alt="Prev" /></a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="sec-actors-transformations.html"><img src="../icons/next.png" alt="Next" /></a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Stage Widget </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">
              <img src="../icons/home.png" alt="Home" />
            </a>
          </td>
          <td width="40%" align="right" valign="top"> Transformations</td>
        </tr>
      </table>
    </div>
  </body>
</html>
